﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Emerald;

using KaroInterface;

namespace RunnableProject
{
    public partial class NewGameDialog : Form
    {
        public NewGameDialog()
        {
            InitializeComponent();
        }

        public Player WhitePlayer
        {
            get {
                if (comboBox1.Text == "Human") 
                    return new HumanPlayer(EColor.White);
                return new AI(EColor.White);
            }
        }
        public IPlayer RedPlayer
        {
            get
            {
                if (comboBox2.Text == "Human") 
                    return new HumanPlayer(EColor.Red);
                if (string.IsNullOrEmpty(DllExternalAi))
                    return new AI(EColor.Red);
                else
                {
                    System.Runtime.Remoting.ObjectHandle objectHandle = Activator.CreateInstanceFrom(DllExternalAi, "Emerald.AI");
                    IPlayer player = (IPlayer) objectHandle.Unwrap();
                    player.SColor = "Red";
                    return player;
                }
            }
        }
        public EColor StartingPlayer
        {
            get
            {
                if (radioButton1.Checked) return EColor.White;
                if (radioButton2.Checked) return EColor.Red;
                return EColor.White;
            }
        }

        string DllExternalAi { get; set; }

        private void button3_Click(object sender, EventArgs e)
        {
            openFileDialog1.FileName = DllExternalAi;
            DialogResult result = openFileDialog1.ShowDialog(this);
            if(result == DialogResult.OK)
            {
                DllExternalAi = openFileDialog1.FileName;
            }
        }
    }
}
